"""taotao URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include, re_path
from django.views.static import serve
from rest_framework.routers import DefaultRouter

from goods.views import GoodsNavViewSet, GoodsListViewSet, GoodsSearchViewSet
from taotao import settings
from trade.views import  AliPayBackViewSet, OrderViewset
from user.views import UserViewset, UserAdressViewSet

router = DefaultRouter()
#用户接口
router.register(r'user', UserViewset, base_name='user')
#首页分类导航
router.register(r'goodsnav',GoodsNavViewSet,base_name='goodsnav')
#创建新商品
router.register(r'publishgood',GoodsListViewSet,base_name='publishgood')
#获取商品列表
router.register(r'goods',GoodsListViewSet,base_name='goods')
#获取收获地址
router.register(r'getaddress',UserAdressViewSet,base_name='getaddress')
# 配置订单的url
router.register(r'orders', OrderViewset, base_name="orders")
# 商品搜索
router.register(r'goodssearch', GoodsSearchViewSet, base_name='goodssearch')

urlpatterns = [
    path('admin/', admin.site.urls),
    path('user_oper/',include('user_operation.urls')),
    # 媒体根路径
    re_path(r'media/(?P<path>.*)', serve, {'document_root': settings.MEDIA_ROOT}),
    # 搜索路由
    path('search/', include('haystack.urls')),
    #path('alipay/return/', AlipayView.as_view()),
    #path('pay/', PayAPIView.as_view()),
    path('aliback/', AliPayBackViewSet.as_view()),
]

urlpatterns += router.urls
